
package com.jjprojects.earutility;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.border.LineBorder;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
 
class CustomTreeRenderer extends DefaultTreeCellRenderer implements TreeCellRenderer
{
	JLabel lblTableColumn;
	int classid=0;
	Font fontPlain = new Font("Sans Serif", Font.PLAIN, 11);
	ImageIcon imgicnRoot = null;
	ImageIcon imgicnProject = null;
	ImageIcon imgicnTestType = null;
	ImageIcon imgicnModule = null;
	ImageIcon imgicnTestCase = null;
	
	String strLabelText = null;
    
    EARFileViewingTool objEARCompareAndViewTool = null;
    
	public CustomTreeRenderer(EARFileViewingTool parent,int clsid)
	{
	    imgicnRoot = new ImageIcon("images/Root.gif");
	    imgicnProject = new ImageIcon("images/Project.gif");
	    imgicnTestType = new ImageIcon("images/TestType.gif");
		imgicnModule = new ImageIcon("images/Module.gif");
		imgicnTestCase = new ImageIcon("images/TestCase.gif");
	    
	    
		objEARCompareAndViewTool = parent;
		classid=clsid;
	}
	public Component getTreeCellRendererComponent(JTree tree, 
	        Object value, boolean selected, boolean expanded, 
	        boolean leaf,int row, boolean hasFocus)
	{
	    setBackgroundSelectionColor(Color.WHITE);
	    setTextNonSelectionColor(Color.BLACK); 
        setTextSelectionColor(Color.BLUE);
        
		if(classid==1)
		{
		    Component c = (super.getTreeCellRendererComponent(tree,value, selected, expanded, leaf, row, hasFocus));
		    lblTableColumn = (JLabel)c;
		    lblTableColumn.setFont(fontPlain);
//		    if(row == 0)
//		    {
//		        lblTableColumn.setIcon(imgicnRoot);
//		    }
		    String strValue = lblTableColumn.getText();
		    
		   
		    if(selected)
	        {
		        strLabelText = lblTableColumn.getText();
		        lblTableColumn.setText("<html><u>" + strLabelText + "</u></html>");
	        }
		}
		return (lblTableColumn);
	}
}